VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmClose 
   BackColor       =   &H00FFFFFF&
   Caption         =   "End of Day"
   ClientHeight    =   5700
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   ControlBox      =   0   'False
   Icon            =   "frmClose.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   5700
   ScaleWidth      =   4680
   StartUpPosition =   1  'CenterOwner
   Begin InetCtlsObjects.Inet Inet1 
      Left            =   0
      Top             =   5160
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      Protocol        =   2
      RemotePort      =   21
      URL             =   "ftp://"
   End
   Begin VB.CommandButton cmdCancel 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   315
      Left            =   2640
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   5220
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdContinue 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "C&ontinue"
      Height          =   315
      Left            =   840
      MaskColor       =   &H00E0E0E0&
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   5220
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "System Close"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   4935
      Left            =   240
      TabIndex        =   8
      Top             =   120
      Width           =   4215
      Begin VB.ListBox lstCloseStatus 
         Height          =   1425
         Left            =   240
         TabIndex        =   13
         Top             =   3240
         Width           =   3675
      End
      Begin VB.ComboBox f498 
         Height          =   315
         Left            =   1320
         TabIndex        =   2
         Top             =   1080
         Width           =   1215
      End
      Begin VB.ComboBox cboName2 
         Height          =   315
         Left            =   1320
         TabIndex        =   0
         Top             =   360
         Width           =   2295
      End
      Begin VB.ComboBox f10 
         Height          =   315
         Left            =   1320
         TabIndex        =   1
         Top             =   720
         Width           =   2295
      End
      Begin VB.Frame Frame2 
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         Caption         =   "Frame1"
         Height          =   1335
         Left            =   720
         TabIndex        =   9
         Top             =   1560
         Width           =   2775
         Begin VB.OptionButton optClose 
            BackColor       =   &H00FFFFFF&
            Caption         =   "Close SmartPost "
            Height          =   255
            Index           =   3
            Left            =   240
            TabIndex        =   15
            Top             =   1080
            Width           =   1935
         End
         Begin VB.OptionButton optClose 
            BackColor       =   &H00FFFFFF&
            Caption         =   "Close FedEx Express"
            Height          =   255
            Index           =   1
            Left            =   240
            TabIndex        =   4
            Top             =   360
            Width           =   1935
         End
         Begin VB.OptionButton optClose 
            BackColor       =   &H00FFFFFF&
            Caption         =   "Close FedEx Ground"
            Height          =   255
            Index           =   2
            Left            =   240
            TabIndex        =   5
            Top             =   720
            Width           =   1935
         End
         Begin VB.OptionButton optClose 
            BackColor       =   &H00FFFFFF&
            Caption         =   "Close Express and Ground"
            Height          =   315
            Index           =   0
            Left            =   240
            TabIndex        =   3
            Top             =   0
            Width           =   2175
         End
      End
      Begin VB.Label Label3 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Close Status:"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   3000
         Width           =   1035
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Sys#:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   12
         Top             =   1140
         Width           =   855
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Name:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   540
         TabIndex        =   11
         Top             =   420
         Width           =   675
      End
      Begin VB.Label Label8 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Acct#:"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   10
         Top             =   780
         Width           =   855
      End
   End
End
Attribute VB_Name = "frmClose"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim rsMeters As ADODB.Recordset


'---------------------------------------------------------------------------------------
' Procedure : cboName2_Click(), f10_Click(),f498_Change()
' DateTime  : 7/26/2004
' Purpose   : These 3 Subs synchronize the account name, number and meter# so that no matter
'             which one is selected the other 2 are updated.
' 2009-01-20, JFW, Can't sync these fields by index, as the lists are group-by and ordered.
'---------------------------------------------------------------------------------------
'
Private Sub cboName2_Click()
    If cboName2.Text = "ALL" Then
        f10.Text = "ALL"
        f498.Text = "ALL"
    ElseIf Not rsMeters.BOF And Not rsMeters.EOF Then
        rsMeters.MoveFirst
        Do
            If rsMeters.EOF Then Exit Do
            If rsMeters.Fields("Name").Value = cboName2.Text Then
                f10.Text = rsMeters!f10
                f498.Text = rsMeters!f498
                Exit Do
            End If
            rsMeters.MoveNext
        Loop
        rsMeters.MoveFirst
    End If
End Sub

Private Sub f10_Click()
    cboName2.Text = "ALL"
    f498.Text = "ALL"
End Sub

Private Sub f498_Click()
    If f498.Text = "ALL" Then
        cboName2.Text = "ALL"
        f10.Text = "ALL"
    ElseIf Not rsMeters.BOF And Not rsMeters.EOF Then
        rsMeters.MoveFirst
        Do
            If rsMeters.EOF Then Exit Do
            If rsMeters.Fields("f498").Value = f498.Text Then
                f10.Text = rsMeters!f10
                cboName2.Text = rsMeters.Fields("Name").Value
                Exit Do
            End If
            rsMeters.MoveNext
        Loop
        rsMeters.MoveFirst
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdCancel_Click()
' DateTime  : 2/18/2004
' Purpose   : Cancel button hides form
'---------------------------------------------------------------------------------------
'
Private Sub cmdCancel_Click()
    
    Call frmShip.EnableButtons
    Me.Hide
    If frmShip.Visible Then frmShip.SetFocus

End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdContinue_Click()
' DateTime  : 9/9/2004
' Purpose   : When Continue button is clicked, Call CloseFXRS passing close type.
'---------------------------------------------------------------------------------------
'
Private Sub cmdContinue_Click()
    
    Dim strMessage As String
    
    'CIC defined routine to run before system close.
    '07/12/06 Changed BeforClose to return a boolean
    If BeforeClose Then
    
        'Check for multiple servers
        If frmSetup.cboFXRSIP.ListCount >= 2 Then
            strMessage = "There are multiple servers configured in your setup." & vbCrLf
            strMessage = strMessage & "If shipping has been performed on any backup server " & vbCrLf
            strMessage = strMessage & "those servers must be closed as well."
        
            MsgBox strMessage, vbInformation, "Multiple Servers"
        End If
        
        Call CloseMeters
    
    End If
    
    cmdCancel.Caption = "&Done"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : CloseMeters()
' DateTime  : 11/11/2004
' Modified  : 20070328-01 Removed code that checks to see if an acct was configured for
'             SmartPost. Also removed SP+ close code.
' Purpose   : Send a Version Capture transaction then close meter(s) selected and carrier(s).
'---------------------------------------------------------------------------------------
'
Private Sub CloseMeters()
    Dim rsAccts As New ADODB.Recordset
    Dim strQuery As String
    Dim strFilename As String
    Dim rsSP As New ADODB.Recordset
    
    On Error GoTo EH

    If f498.Text <> "ALL" Then
        
        lstCloseStatus.AddItem "Closing Meter#: " & f498.Text
        If optClose(0) Then
            Call SendData(BuildCloseTrans("", "", f498.Text))
        ElseIf optClose(1) Then
            Call SendData(BuildCloseTrans("", "FDXE", f498.Text))
        ElseIf optClose(2) Then
            Call SendData(BuildCloseTrans("", "FDXG", f498.Text))
        End If

    ElseIf f10 = "ALL" Then
        strQuery = "SELECT f10 FROM Meters group by f10 order by f10"
        rsAccts.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
        
        Do Until rsAccts.EOF
            
            'Set boolean to false to hold execution until FXRS reply received
            g_blnNextClose = False
            
            lstCloseStatus.AddItem "Closing Acct#: " & rsAccts!f10
            If optClose(0) Then
                Call SendData(BuildCloseTrans(rsAccts!f10))
            ElseIf optClose(1) Then
                Call SendData(BuildCloseTrans(rsAccts!f10, "FDXE"))
            ElseIf optClose(2) Then
                Call SendData(BuildCloseTrans(rsAccts!f10, "FDXG"))
            ElseIf optClose(3) Then
                lstCloseStatus.AddItem "Closing SmartPost"
                Call CloseSmartPost
            End If
            
            Do Until g_blnNextClose
                DoEvents
            Loop
            
            rsAccts.MoveNext
        Loop
    
    ElseIf f10 = "" Then
        MsgBox "Please select an account to close."
        cboName2.SetFocus
    Else
        
        lstCloseStatus.AddItem "Closing Acct#: " & f10
        If optClose(0) Then
            Call SendData(BuildCloseTrans(f10))
        ElseIf optClose(1) Then
            Call SendData(BuildCloseTrans(f10, "FDXE"))
        ElseIf optClose(2) Then
            Call SendData(BuildCloseTrans(f10, "FDXG"))
        ElseIf optClose(3) Then
            
            'Set boolean to false to hold execution until FXRS reply received
            g_blnNextClose = False

            lstCloseStatus.AddItem "Closing SmartPost"
            Call CloseSmartPost
        End If
    End If

Release:
    If rsAccts.State = adStateOpen Then rsAccts.Close
    Set rsAccts = Nothing
    If rsSP.State = adStateOpen Then rsSP.Close
    Set rsAccts = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, "frmClose:CloseMeters"
    Resume Release
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 7/26/2004
' Purpose   : Sets Cancel button caption back to Cancel
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    cmdCancel.Caption = "&Cancel"
    cboName2.SetFocus
        If f10.ListCount > 1 Then
            f10.ListIndex = 0
        ElseIf f10.ListCount = 1 Then
            f10.ListIndex = 0
        End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 2/18/2004
' Purpose   : Set Close Express and Ground as default.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()
    With frmSetup
        Call LoadAcctNumCombo(f10, .f10)
        Call LoadNameCombo(cboName2, .cboName)
        Call LoadMetersCombo(f498, .f498)
        If f10.ListCount > 1 Then
            cboName2.AddItem "ALL", 0
            f498.AddItem "ALL", 0
            f10.AddItem "ALL", 0
            f10.ListIndex = 0
        ElseIf f10.ListCount = 1 Then
            f10.ListIndex = 0
        End If
    End With
    
    Set rsMeters = New ADODB.Recordset
    rsMeters.Open "SELECT Name, f498, f10 FROM Meters group by Name, f498, f10 order by Name" _
            , g_connFSMSClient, adOpenStatic, adLockReadOnly

    optClose(0).Value = True
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Inet1_StateChanged()
' DateTime  : 4/6/2005
' Purpose   : Updates the Status for Inet1 control used in SmartPost FTP process
'---------------------------------------------------------------------------------------
'
Private Sub Inet1_StateChanged(ByVal State As Integer)

    On Error GoTo EH

    Select Case State
        Case 1 'icHostResolvingHost
            lstCloseStatus.AddItem "Resolving Host..."
'        Case 2 'icHostResolved
'            lstCloseStatus.AddItem "Host Resolved!"
'        Case 3 'icConnecting
'            lstCloseStatus.AddItem "Connecting..."
        Case 4 'icConnected
            lstCloseStatus.AddItem "Connected!"
'        Case 5 'icRequesting
'            lstCloseStatus.AddItem "Requesting..."
'        Case 6 'icRequestSent
'            lstCloseStatus.AddItem "Request Sent"
'        Case 7 'icReceivingResponse
'            lstCloseStatus.AddItem "icReceivingResponse"
'        Case 8 'icResponseReceived
'            lstCloseStatus.AddItem "Response Received!"
'        Case 9 'icDisconnecting
'            lstCloseStatus.AddItem "Disconnecting..."
        Case 10 'icDisconnected
            lstCloseStatus.AddItem "Disconnected."
        Case 11 'icError
            MsgBox Inet1.ResponseInfo
        Case 12 'icResponseCompleted
            '20070829-02 changed to remove chars rather than use Left statement.
            lstCloseStatus.AddItem StripASCIIUnprintable(Inet1.ResponseInfo)
    End Select

    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, "frmClose:Inet1_StateChanged"

End Sub
